home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 24
/
Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso
/
Aminet
/
comm
/
mail
/
octetpurge.lha
/
OctetPurge
/
OctetPurge.bas
< prev
next >
Wrap
BASIC Source File
|
1998-02-05
|
4KB
|
171 lines
REM Octet Purger 1.1 by Simon N Goodwin, December 1997.
REM Updated February 1998 to fix the 'NOT Copying' bug
REM
REM WHAT?
REM
REM Program to scan MIME a mail file and remove all
REM octet-stream binary encoded data sections.
REM
REM REQUIREMENTS
REM
REM Written in HiSoft BASIC. Requires ASL library.
REM Uses 15 point Helvetica.font if it's available.
REM
REM WHY?
REM
REM Written to keep the size of archived YAM mail
REM manageable, on the basis that binary contents
REM ought to be archived somewhere else already.
REM
REM HOW?
REM
REM Start from Workbench by clicking on the icon.
REM Select a file to be scanned or CANCEL to quit.
REM Repeat selection for each file to be purged.
REM
REM Input file is not modified. A new file on the
REM same path with the suffix ".purged" is created
REM containing the original contents except with
REM the 'application octet-stream' data sections
REM replaced with the text:
REM
REM **** Octet stream deleted from archive.
REM
REM KNOWN BUGS
REM
REM No check that the output file name is valid.
REM No diagnostics if the input file is malformed.
REM
REM In HiSoft BASIC, NOT 1 = TRUE! This stopped
REM the first release copying the first part of
REM the file. This has been fixed in version 1.1.
REM
REM
REM STATUS
REM
REM Freely distributable; you must include source.
REM
REM AUTHOR
REM
REM Simon N Goodwin, simon@studio.woden.com
REM
DEFINT a-z
' HiSoft ASL library and disk font initialisation
REM $INCLUDE diskfont.bh
REM $INCLUDE graphics.bh
REM $include asl.bh
LIBRARY OPEN "asl.library"
LIBRARY OPEN "diskfont.library"
LIBRARY OPEN "graphics.library"
WINDOW 1," MIME Mail archive file Octet Purger v1.1 ", _
(32,16)-(608,160),1+2+4+16+256
REM Use a groovier Compugraphic fo(u)nt if you wish
DIM TextAttr(4)
InitTextAttr TextAttr(),"Helvetica.font",15,0,0
font& = OpenDiskFont (VARPTR(TextAttr(0)))
IF font&
SetFont WINDOW (8), font&
ELSE
PRINT " **** Preferred font not available. Using default."
END IF
pattern$="Content-Type: application/octet-stream"
patlen=LEN(pattern$)
boundary$="--BOUNDARY"
boundlen=LEN(boundary$)
' ASL requester initialisation
CONST TAG_DONE&=0,TRUE&=1,ABORT&=-1,FALSE&=0
DIM frtags&(20)
' Main program
ok=TRUE
REPEAT main
TAGLIST VARPTR(frtags&(0)),ASLFR_TitleText&, _
"Select the file to be purged", _
ASLFR_InitialFile&,"", _
ASLFR_InitialDrawer&,"RAM:", _
ASLFR_InitialHeight&, 130, _
ASLFR_InitialLeftEdge&, 280, _
ASLFR_InitialWidth&, 310, _
TAG_DONE&
fr&=AllocAslRequest&(ASL_FileRequest&,VARPTR(frtags&(0)))
IF fr& THEN
ok&=AslRequest&(fr&,0)
IF ok& THEN
file$=PEEK$(PEEKL(fr&+fr_File))
dir$=PEEK$(PEEKL(fr&+fr_Drawer))
IF LEN(dir$)
suffix$=RIGHT$(dir$,1)
IF suffix$<>"/" AND suffix$<>":" THEN dir$=dir$+"/"
END IF
END IF
FreeASlRequest fr&
ELSE
ok&=ABORT&
END IF
IF ok&=FALSE& OR ok&=ABORT& THEN EXIT main
file$=dir$+file$
PRINT
OPEN file$ FOR INPUT AS #3
OPEN file$+".purged" FOR OUTPUT AS #4
copying=1 : found=0
REPEAT scan
IF EOF(3) THEN EXIT scan
INPUT #3,a$
IF copying=0
copying=LEFT$(a$,boundlen)=boundary$
END IF
IF LEFT$(a$,patlen)=pattern$
PRINT #4,a$
PRINT " Purging: ";a$
PRINT #4
PRINT #4,"**** Octet stream deleted from archive."
PRINT #4
copying=0: found=found+1
END IF
IF copying THEN PRINT #4,a$ :REM debug PRINT a$
END REPEAT scan
CLOSE #4
CLOSE #3
PRINT
PRINT " OK,";found;"octet stream";
IF found<>1 THEN PRINT "s";
PRINT " found in ";file$
PRINT
PRINT " Condensed version written to ";file$+".purged"
END REPEAT main
SYSTEM
SUB InitTextAttr(T(1),FontName$,BYVAL Height,BYVAL style,BYVAL flags)
POKEL VARPTR(T(0))+ta_Name,SADD(FontName$+CHR$(0))
t(ta_YSize\2)=Height
POKEB VARPTR(T(0))+ta_Style,style
POKEB VARPTR(T(0))+ta_Flags,flags
END SUB ' InitTextAttr